package com.zanfeng.signleplatform.dao.persistence.dao;

import com.zanfeng.signleplatform.api.result.modules.role.RoleResult;
import com.zanfeng.signleplatform.base.BaseMapper;
import com.zanfeng.signleplatform.dao.persistence.entity.Account;
import com.zanfeng.signleplatform.dao.persistence.entity.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface RoleMapper extends BaseMapper<Role> {

    //  列表查询
    List<com.zanfeng.signleplatform.api.result.modules.role.RoleResult> queryRoleList(Map paramMap);

    //  根据ID列表逻辑删除
    void deleteRoleListByIdList(List<Integer> idList);

    // 根据角色名查询角色信息
    @Select("select * from wt_role WHERE role_name = #{roleName} AND is_delete = 0 limit 1")
    Role findRoleByRolename(@Param("roleName") String roleName);

    //  查询role_id对应的权限id列表
    @Select("select permission_id from wt_role_permission where role_id = #{roleId}")
    List<Integer> queryPermissionIdListByRoleId(@Param("roleId") Integer roleId);

    //  查询全部可用的角色
    @Select("SELECT * FROM `wt_role` WHERE is_publish = 1 AND is_delete = 0 ORDER BY order_num DESC")
    List<RoleResult> queryRoleActiveList();
}